from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get("https://www.baidu.com/")
driver.implicitly_wait(15)
driver.maximize_window()

# 定位到设置
set = driver.find_element(By.ID,"s-usersetting-top")
ActionChains(driver).move_to_element(set).perform()

# 点击搜索设置
driver.find_element(By.XPATH,"//*[text()='搜索设置']").click()

# 点击保存设置
driver.find_element(By.XPATH,"//*[text()='保存设置']").click()

#点击alert中确定
alert = driver.switch_to.alert
alert.accept()

#对弹窗进行取消操作
# alert = driver.switch_to.alert
# alert.dismiss()

# 获取当前的URL
print(driver.current_url)

